import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'dva'
import Login from './Login.js'
import styles from './Login.less'
import { Spin, message } from 'antd'

function LoginIndex({dispatch, loginload}) {
  const loginProps = {
    loginload,
    onOk (data) {
      dispatch({type: 'app/login', payload: data})
    }
  }
  return (
    <div className={styles.spin}>
      <Spin tip='加载中...' spinning={loginload} size='large'>
        <Login {...loginProps} />
      </Spin>
    </div>
  );
}

LoginIndex.propTypes = {
  dispatch: PropTypes.func,
  loginload: PropTypes.bool
};

function mapStateToProps(State) {
      //return { loading: loading.models.app }
      const {loginload } = State.app;
      return {loginload : loginload}
}

export default connect(mapStateToProps)(LoginIndex);
